import os

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp import template

import models

class Trips(webapp.RequestHandler):
	def get(self):
		path = os.path.join(os.path.dirname(__file__), 'templates/trips.html')
		self.response.out.write(template.render(path,{'trips': models.Trip.all()}))

class Trip(webapp.RequestHandler):
	def get(self, key):
		path = os.path.join(os.path.dirname(__file__), 'templates/trip.html')
		self.response.out.write(template.render(path,{'trip':models.Trip.get(key)}))

application = webapp.WSGIApplication([
	('/trips/', Trips),
	('/trips/(.*)', Trip),
],debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
